<?php 
	function create_summary($text,$num){

        $text = strip_tags($text);

        if(mb_strlen($text,'UTF-8') > $num){

            $endpos = mb_strpos($text,' ',$num,'UTF-8');
            $dots = '...';
            if(!$endpos){
                $endpos = mb_strlen($text,'UTF-8');
                $dots = '';
            }

        }else{
            $endpos = mb_strlen($text,'UTF-8');
            $dots ='';
        }                   
        return mb_substr($text,0,$endpos,'UTF-8').$dots;
    }
?>
<?php 
if(isset($_SESSION['config_template']))
{
	if($_SESSION['config_template']=='layoutmain_web1')
	{
	?>
	<link href="/css/web1/slideshow.css" type="text/css" rel="stylesheet">
	<script src="/js/web1/jquery.easing.js" type="text/javascript" language="javascript"></script>
	<script src="/js/web1/script (2).js" type="text/javascript" language="javascript"></script>
	<script type="text/javascript">
						 $(document).ready( function(){	
								var buttons = { previous:$('#lofslidecontent45 .lof-previous') ,
												next:$('#lofslidecontent45 .lof-next') };
												
								$obj = $('#lofslidecontent45').lofJSidernews( { interval : 4000,
																		direction		: 'opacitys',	
																		easing			: 'easeInOutExpo',
																		duration		: 1200,
																		auto		 	: false,
																		maxItemDisplay  : 4,
																		navPosition     : 'horizontal', // horizontal
																		navigatorHeight : 32,
																		navigatorWidth  : 80,
																		mainWidth:700,
																		buttons			: buttons} );	
							});
						</script>
						
	<div>		
					<!--content rows-->
					<div class="content_block">
						<div class="home_head">
							<div class="left_home_head"><span></span></div>
							<div class="center_home_head">
								<h2 style="float: left; width:20%; background:url(../../images/web1/icon_08.gif) no-repeat 100% 0% !important;"><?php echo $title;?></h2>
								<?php if(isset($permission) && $permission=="true") { ?>
									<ul class="gallery clearfix" style = "float:left;margin-left:18px; margin-top:8px;">
										<a href="/slideshow/clickchange?iframe=true&width=370&height=210" rel="prettyPhoto[iframe]">
											<img src="/images/Pencil.png" style="width:20px ; height:20px;"></img>
										</a>
									</ul>
								<?php } ?>
							</div>
							<div class="right_home_head"><span></span></div>
							<div class="clear_both1"><span></span></div>
						</div>
						<div class="content_best">
							<div class="c_r_row">
							<div style="width:700px; height:310px; margin:0 auto;" class="lof-slidecontent" id="lofslidecontent45">
								<div class="preload" style="display: none;"><div></div></div>
									<!-- MAIN CONTENT --> 
										<div style="width:700px; height:310px;" class="lof-main-outer">
											<ul class="lof-main-wapper" style="left: 0px; width: 1400px;">
											<?php if(count($News) > 0){$count=0;?>
											<?php foreach ($News as $new)
											{
												$count++;
												$title_maxlen=strlen($new['title']);
												$des_maxlen=strlen($new['description'])
											?>
												<li>
															<img title="<?php echo $new['title'];?>" src="<?php if($new["avatar"] != NULL){echo $new["avatar"];}else{ echo '/images/noimage.jpg';} ?>">           
															 <div class="lof-main-item-desc">
															<h2 style="color:white"><?php if ($title_maxlen<=30) echo $new["title"]; else echo substr($new['title'], 0,28).".."; ?></h2>
															<p><?php if ($des_maxlen<=47){echo $new["description"];}else{echo create_summary($new['description'],45);}?>
															&nbsp<a href="/news/detail?id=<?php echo $new["thing_id"] ?>" class="readmore"><?php echo $textReadMore;?></a>
															</p>
															
														 </div>
												</li>
												<?php }} ?>
											</ul>  	
											</div>
									<!-- END MAIN CONTENT --> 
										
									<!-- NAVIGATOR -->
												<div class="lof-navigator-wapper">
												
													<div class="lof-next" href="" onclick="return false"><?php echo $textNext;?></div>
													  <div class="lof-navigator-outer" style="width: 160px; height: 32px;">
															<ul class="lof-navigator" style="width: 160px; left: 0px;">
															<?php  
														$count=0;
														foreach ($News as $new)
														{
															$count++;
														?>
													<li style="height: 32px; width: 80px;" class="active">
															<img src="<?php if($new["avatar"] != NULL){echo $new["avatar"];}else{ echo '/images/noimage.jpg';} ?>">
													</li> 
													<?php } ?>    		
															</ul>
													  </div>
														<div class="lof-previous" href="" onclick="return false"><?php echo $textPrevious;?></div>
												 </div> 
												  <!----------------- --------------------->
										 </div> 
										 
								
							</div><!--end row-->
						</div>
						<div class="bottom_best"><span></span></div>
					</div>

					
					</div>
	
	<?php 
	}
	else 
	{
		if($_SESSION['config_template']=='layoutmain_web2')
		{?>
			<!--slide show-->		
			<link rel="stylesheet" type="text/css" href="/css/web2/slideshow.css" />
			<script language="javascript" type="text/javascript" src="js/web2/jquery.easing.js"></script>
			<script language="javascript" type="text/javascript" src="/js/script.js"></script>			
			<script language="javascript" type="text/javascript" src="js/web2/slideshowscript.js"></script>
						<script type="text/javascript">
						 $(document).ready( function(){	
								var buttons = { previous:$('#lofslidecontent45 .lof-previous') ,
												next:$('#lofslidecontent45 .lof-next') };
												
								$obj = $('#lofslidecontent45').lofJSidernews( { interval : 4000,
																		direction		: 'opacitys',	
																		easing			: 'easeInOutExpo',
																		duration		: 1200,
																		auto		 	: false,
																		maxItemDisplay  : 4,
																		navPosition     : 'horizontal', // horizontal
																		navigatorHeight : 32,
																		navigatorWidth  : 80,
																		mainWidth       :700,
																		buttons			: buttons} );	
							});
			</script>
			<div class="content_block">
					<div class="content_block_left">
						<div class="product_head">
							<h2><span style="float:left;width:97%;"><?php echo $title;?></span>
							<?php if(isset($permission) && $permission=="true") {?>
							<!-- Tạo cây bút chì cho click and change -->
							<div class="floatright">
								<div id="pageindex">
									<ul class="gallery clearfix">
										<a href="/slideshow/clickchange?iframe=true&width=370&height=210" rel="prettyPhoto[iframe]">
											<img src="/images/Pencil.png" style="width:20px ; height:20px; "></img>
										</a>
									</ul>
								</div>
							</div>
							<!-- End - Tạo cây bút chì cho click and change -->
							<?php } ?></h2>
						</div>
						
						<div id="lofslidecontent45" class="lof-slidecontent" style="width:700px; height:310px;">
							<div class="preload"><div></div></div>
							<?php if(count($News) > 0){?>
							 <!-- MAIN CONTENT --> 
							  <div class="lof-main-outer" style="width:700px; height:310px;">
								<ul class="lof-main-wapper">
									<?php  
									$count=0;
									foreach ($News as $new)
									{
										$count++;
										$title_maxlen=strlen($new['title']);
										$des_maxlen=strlen($new['description'])
									?>
									<li>
										<img style="width:700px; height:243px;" src="<?php if($new["avatar"] != NULL){echo $new["avatar"];}else{ echo '/images/noimage.jpg';} ?>" title="<?php echo $new['title'];?>" >           
										<div class="lof-main-item-desc">
											<h2><?php if ($title_maxlen<=30) echo $new["title"]; else echo substr($new['title'], 0,28).".."; ?></h2>
											<p><?php if ($des_maxlen<=47){echo $new["description"];}else{echo create_summary($new['description'],45);}?>
											&nbsp<a href="/news/detail?id=<?php echo $new["thing_id"] ?>"><?php echo $textReadMore;?></a>
											</p>
										 </div>
									</li>
									<?php }?> 					   
								  </ul>  	
							  </div>
								  <!-- END MAIN CONTENT --> 
									<!-- NAVIGATOR -->
								<div class="lof-navigator-wapper">
						
										<div onclick="return false" href="" class="lof-next"><?php echo $textNext;?></div>
									  <div class="lof-navigator-outer">
											<ul class="lof-navigator">
												<?php  
													$count=0;
													foreach ($News as $new)
													{
														$count++;
													?>
												<li>
													<img src="<?php if($new["avatar"] != NULL){echo $new["avatar"];}else{ echo '/images/noimage.jpg';} ?>"/>
												</li> 
												<?php }?>       		
											</ul>
									  </div>
										<div onclick="return false" href="" class="lof-previous"><?php echo $textPrevious;?></div>
								 </div> 
								  <!----------------- --------------------->
								<?php }else{?>
								<br />
								<div class="c_r_row">
								<?php echo $textNoNew;?>
								</div>
								<?php }?>
						</div>
					</div>
				</div>			

			<!--end slide show-->
			
		<?php }
		else 
		{?>		
			<link rel="stylesheet" type="text/css" href="/css/slideshow.css" />
			<script language="javascript" type="text/javascript" src="/js/jquery.easing.js"></script>
			<script language="javascript" type="text/javascript" src="/js/script.js"></script>
			<script type="text/javascript">
			 $(document).ready( function(){	
					var buttons = { previous:$('#lofslidecontent45 .lof-previous') ,
									next:$('#lofslidecontent45 .lof-next') };
									
					$obj = $('#lofslidecontent45').lofJSidernews( { interval : 4000,
															direction		: 'opacitys',	
															easing			: 'easeInOutExpo',
															duration		: 1200,
															auto		 	: false,
															maxItemDisplay  : 4,
															navPosition     : 'horizontal', // horizontal
															navigatorHeight : 32,
															navigatorWidth  : 80,
															mainWidth:700,
															buttons			: buttons} );	
				});
</script>

<div>		
<div style="float: left;"><p><?php echo $title?></p></div>
<div style="float: left;">
<?php if(isset($permission) && $permission=="true") {?>
<ul class="gallery clearfix">
							<a href="/slideshow/clickchange?iframe=true&width=370&height=210" rel="prettyPhoto[iframe]">
								<img src="/images/Pencil.png" style="width:20px ; height:20px; "></img>
							</a>
</ul>
<?php }?>
						</div>
<div class="line"><hr></div>
<?php if(count($News) > 0){?>
<!--content rows-->
<div class="c_r_row">
	<div id="lofslidecontent45" class="lof-slidecontent" style="width:700px; height:310px;margin-top:50px">
		<div class="preload"><div></div></div>
			<!-- MAIN CONTENT --> 
				<div class="lof-main-outer" style="width:700px; height:310px;">
					<ul class="lof-main-wapper">
						<?php  
						$count=0;
						foreach ($News as $new)
						{
							$count++;
							$title_maxlen=strlen($new['title']);
							$des_maxlen=strlen($new['description'])
						?>
							<li>
									<img src="<?php if($new["avatar"] != NULL){echo $new["avatar"];}else{ echo '/images/noimage.jpg';} ?>" title="Newsflash 2" >           
									 <div class="lof-main-item-desc">
									
									<h2><?php if ($title_maxlen<=30) {echo $new["title"];} else {echo substr($new['title'], 0,28).".."; }?></h2>
									<p><?php if ($des_maxlen<=47){echo $new["description"];}else{echo create_summary($new['description'],45);}?>
											&nbsp<a href="/news/detail?id=<?php echo $new["thing_id"] ?>"><?php echo $textReadMore;?></a>
											</p>
								 </div>
							</li> 
							<?php }?>
						
						  </ul>  	
					</div>
			<!-- END MAIN CONTENT --> 
			<!-- NAVIGATOR -->
						<div class="lof-navigator-wapper">

								<div onclick="return false" href="" class="lof-next"><?php echo $textNext;?></div>
							  <div class="lof-navigator-outer">
									<ul class="lof-navigator">
										<?php  
										$count=0;
										foreach ($News as $new)
										{
											$count++;
										?>
							<li>
									<img src="<?php if($new["avatar"] != NULL){echo $new["avatar"];}else{ echo '/images/noimage.jpg';} ?>"/>
							</li> 
							<?php }?>
									      		
									</ul>
							  </div>
								<div onclick="return false" href="" class="lof-previous"><?php echo $textPrevious;?></div>
						 </div> 
						  <!----------------- --------------------->
				 </div> 						
	</div><!--end row-->
	<?php }else{?>
	<br />
	<div class="c_r_row">
	<?php echo $textNoNew;?>
	</div>
	<?php }?>
</div>	
<?php }
	}
}?>

<div style="clear: both;"></div>